/**
 * Copyright © 2016-2020 The Thingsboard Authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.thingsboard.server.common.data.exception;

import com.fasterxml.jackson.annotation.JsonValue;

public enum ThingsboardErrorCode {

    GENERAL(2),
    AUTHENTICATION(10),
    JWT_TOKEN_EXPIRED(11),
    CREDENTIALS_EXPIRED(15),
    PERMISSION_DENIED(20),
    INVALID_ARGUMENTS(30),
    BAD_REQUEST_PARAMS(31),
    ITEM_NOT_FOUND(32),
    TOO_MANY_REQUESTS(33),
    TOO_MANY_UPDATES(34),
    ERROR_4000(4000,"内部错误导致的请求失败"),
    ERROR_4001(4001,"参数验证引起的错误"),
    ERROR_4002(4002,"缺少必要参数"),
    ERROR_4003(4003,"设备已存在"),
    ERROR_4004(4004,"设备不存在"),
    ERROR_5040(5040,"设备连接超时"),
    ERROR_5041(5041,"设备响应结果为失败"),
    ERROR_5042(5042,"前设备不在线");


//            4000	内部错误导致的请求失败
//            4001	参数验证引起的错误，参数类型错误或者参数不合法（平台不会对参数逐一进行验证）。
//            4002	缺少必要参数，请检查提交参数项。
//            4003	设备已存在，请检查设备编码是否重复。
//            4004	设备不存在，请检查设备编码是否正确。
//            5040	设备连接超时。
//            5041	设备响应结果为失败，具体异常内容参考设备报文协议。
//            5042	当前设备不在线







    private int errorCode;

    private String message;

    ThingsboardErrorCode(int errorCode) {
        this.errorCode = errorCode;
    }

    ThingsboardErrorCode(int errorCode,String message){
        this.errorCode=errorCode;
        this.message=message;
    }

    @JsonValue
    public int getErrorCode() {
        return errorCode;
    }
    @JsonValue
    public String getMessage() {
        return message;
    }
}
